<template>
	<view>
		<u-tabbar :value="value" :safeAreaInsetBottom="true" :fixed="true" :placeholder="true">
			<u-tabbar-item text="首页" icon="home" @click="goto('/pages/index/index')"></u-tabbar-item>
			<u-tabbar-item text="提醒" icon="photo" @click="goto('/pages/reminder/reminder')"></u-tabbar-item>
			<u-tabbar-item text="运动圈" icon="play-right" @click="goto('/pages/exercise/exercise')"></u-tabbar-item>
			<u-tabbar-item text="我的" icon="account" @click="goto('/pages/me/me')"></u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
	export default {
		name: "tabbar",
		data() {
			return {
				value: 1
			};
		},
		methods: {
			goto(path) {
				console.log(path);
				uni.switchTab({
					url: path
				})
			},
		},
		created() {
			const pages = getCurrentPages(); // 获取页面栈
			const currentPage = pages[pages.length - 1]; // 获取当前页面
			const route = currentPage.route; // 获取当前页面的路径
			let path = route
			if (path == 'pages/index/index') {
				this.value = 0
			} else if (path == 'pages/reminder/reminder') {
				this.value = 1
			} else if (path == 'pages/exercise/exercise') {
				this.value = 2
			}
			if (path == 'pages/me/me') {
				this.value = 3
			}
		}

	}
</script>

<style>

</style>